package com.example.thumbsupdemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.EditText

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val count: EditText = findViewById(R.id.thumbs_up_count)
        val set: Button = findViewById(R.id.button_set)
        val thumbsUpView: ThumbsUpView = findViewById(R.id.main_container)
        set.setOnClickListener {
            var text = count.text.toString()
            if (text.isNotEmpty()) {
                if (text.length > 7) {
                    text = text.substring(0, 7)
                }
                val i = Integer.parseInt(text)
                thumbsUpView.setCount(i)
            }
        }
    }
}